package org.ricks.jdk25;

/**
 * 灵活构造函数体 （JEP 513）
 */
public class GamePlayer {

    private String playerId;

    public GamePlayer(String playerId) {
        System.err.println("还没有初始化对象");
        this.playerId = validateId(playerId); // 构造前校验ID格式
        super(); // 调用父类构造函数;
        System.err.println("父类对象初始化");
    }

    public static String validateId(String id) {
        if (id == null) throw new IllegalArgumentException("角色ID无效");
        return id.trim();
    }


    static void main() {
        GamePlayer gamePlayer = new GamePlayer(null);
    }
}
